package EjemplosEventosBasicos;

import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;

import javax.swing.JFrame;
import javax.swing.JTextField;

public class EjemploKeyListener2 {
	public void montarVentana (){
		JFrame frame = new JFrame();
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		
		JTextField text = new JTextField();
		
		text.addKeyListener(new KeyAdapter(){

			public void keyPressed(KeyEvent e) {
				if( e.getKeyCode() == 10 ){
					System.out.println("Has pulsado Intro");
				}
			}
			
		});
		
		
		frame.add(text);
		frame.setVisible(true);
		frame.pack();
	}
	
	public static void main (String[] args){
		EjemploKeyListener2 ekl = new EjemploKeyListener2();
		ekl.montarVentana();
	}
}
